﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PhysicsSimulator
{
    class CSprite
    {
        private Texture2D _texture = null;
        public Texture2D Texture
        {
            get
            {
                return _texture;
            }
            set 
            {
                _texture = value;
            }
        }

        private Vector2 _center = Vector2.Zero;
        public Vector2 Center
        {
            get
            {
                return _center;
            }
            protected set
            {
                _center = value;
            }
        }

        //anchor
        private Vector2 _anchor = new Vector2(0.5f, 0.5f);
        public Vector2 Anchor
        {
            get
            {
                return _anchor;
            }
            set
            {
                _anchor = value;
                _origin.X = _width * _anchor.X;
                _origin.Y = _height * _anchor.Y;
            }
        }
        //origin
        private Vector2 _origin = Vector2.Zero;
        public Vector2 Origin
        {
            get
            {
                return _origin;
            }
            set
            {
                _origin = value;
            }
        }

        //position
        private Vector2 _position = Vector2.Zero;
        public Vector2 Position
        {
            get
            {
                return _position;
            }
            set
            {
                _position = value;
            }
        }

        public void setPositionY(float y)
        {
            _position.Y = y;
        }

        public void setPositionX(float x)
        {
            _position.X = x;
        }
        //rotation
        private float _rotation = 0.0f;
        public float Rotation
        {
            get
            {
                return _rotation;
            }
            set
            {
                _rotation = value;
            }
        }

        //scale
        private float _scale = 1.0f;
        public float Scale
        {
            get
            {
                return _scale;
            }
            set
            {
                _scale = value;
            }
        }

        private int _width = 0;
        public int Width
        {
            get
            {
                return _width;
            }
            protected set
            {
                _width = value;
            }
        }

        private int _height = 0;
        public int Height
        {
            get
            {
                return _height;
            }
            protected set
            {
                _height = value;
            }
        }

        public CSprite(Texture2D texture)
        {
            _texture = texture;

            _width = texture.Width;
            _height = texture.Height;

            _center.X = _width / 2;
            _center.Y = _height / 2;

            _origin.X = _width * _anchor.X;
            _origin.Y = _height * _anchor.Y;            
        }      
    }
}
